package com.cty.advice;


import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

//事务的普通切面
@Component
@Aspect
@Order(10)
public class TxAdvice {

    //开启事务
    @Before("com.cty.pointcut.MyPc.pc()")
    public void begin() {
        System.out.println("开启事务");
    }

    @AfterReturning("com.cty.pointcut.MyPc.pc()")
    public void commit() {
        System.out.println("提交事务");
    }

    @AfterThrowing("com.cty.pointcut.MyPc.pc()")
    public void RollBack() {
        System.out.println("事务回滚");
    }
}
